package com.suray.socket.core;

import lombok.Data;

import java.util.Objects;

@Data
public class NetAddress {
    private Integer id;
    private String ip;
    private int port;

    public NetAddress(Integer id, String ip, int port) {
        this.id = id;
        this.ip = ip;
        this.port = port;
    }

    public NetAddress(String ip, int port) {
        this.ip = ip;
        this.port = port;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        NetAddress that = (NetAddress) o;
        return port == that.port &&
                Objects.equals(ip, that.ip);
    }

    @Override
    public int hashCode() {
        return Objects.hash(ip, port);
    }

    @Override
    public String toString() {
        return "NetAddress{" +
                "id='" + id + '\'' +
                "ip='" + ip + '\'' +
                ", port=" + port +
                '}';
    }
}
